package http

import "net/http"

// 文档参考 https://studygolang.com/articles/20565
// ops 只接受一个参数，多出的会忽略掉
// !! 注意不要在url, 和ops中同时带查询参数，其中之一设置即可，建议在ops中统一设置

var (
	resuse = true
)

func Get(url string, ops ...*Options) (res []byte, resp *http.Response, err error) {
	if resuse {
		return requestv2(GET, url, ops...)
	}

	return request(GET, url, ops...)
}

func Post(url string, ops ...*Options) (res []byte, resp *http.Response, err error) {
	if resuse {
		return requestv2(POST, url, ops...)
	}

	return request(POST, url, ops...)
}

func Put(url string, ops ...*Options) (res []byte, resp *http.Response, err error) {
	if resuse {
		return requestv2(PUT, url, ops...)
	}

	return request(PUT, url, ops...)
}

func Delete(url string, ops ...*Options) (res []byte, resp *http.Response, err error) {
	if resuse {
		return requestv2(DELETE, url, ops...)
	}

	return request(DELETE, url, ops...)
}
